package ink.lovejinhu.leetcode;

import java.util.List;

/**
 * @author jinhu
 * created 2021-08-01 15:25
 */
public class Solution_0690 {
    public int sum = 0;

    public int getImportance(List<Employee> employees, int id) {
        //先找这个人
        for (int i = 0; i < employees.size(); i++) {
            if (id == employees.get(i).id) {
                sum += employees.get(i).importance;
                System.out.println(sum);
                //employees.remove(i);
                List<Integer> subordinates = employees.get(i).subordinates;
                for (int j = 0; j < subordinates.size(); j++) {
                    getImportance(employees, subordinates.get(j));
                }
                break;
            }

        }
        return sum;
    }

    class Employee {
        public int id;
        public int importance;
        public List<Integer> subordinates;
    }
}
